#include<bits/stdc++.h>
using namespace std;
int n,ans=0;

int main(){
    freopen("duel.in","r",stdin);
    freopen("duel.out","w",stdout);
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        sort(a,a+i+1);
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(a[i]<a[j] && i<j){
                a[i]=0;
                a[j]=1;
                break;
            }
        }
    }
    for(int i=0;i<n;i++){
        cout<<a[i]<<" ";
        if(a[i]!=0)ans++;
    }
    cout<<ans;
    return 0;
}
